import {{ entity_package }};
import {{ service_package }};
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;

/**
 * @detail {{ class_name }}控制器
 * @author {{ createName }}
 * @date  {{ date }}
 **/

@SuppressWarnings("ALL")
@Controller
@RequestMapping("/{{small_class_name}}")
public class {{class_name}}Controller {
    @Autowired
    {{class_name}}Service {{small_class_name}}Service;
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    private int add(HttpServletRequest request) {
        {{class_name}} {{small_class_name}} = new {{class_name}}();
        return {{small_class_name}}Service.save{{class_name}}({{small_class_name}});
    }

    @RequestMapping(value = "/list/{page}/{pageSize}", method = RequestMethod.GET)
    @ResponseBody
    private PageInfo<{{class_name}}> list(HttpServletRequest request, @PathVariable int page,@PathVariable int pageSize) {
         {{class_name}} {{small_class_name}} = new  {{class_name}}();
        return {{small_class_name}}Service.getAll{{class_name}}ByPage({{small_class_name}}, page, pageSize);
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    private int delete(HttpServletRequest request, @PathVariable int id) {
         {{class_name}} {{small_class_name}} = new  {{class_name}}();
        return {{small_class_name}}Service.delete{{class_name}}({{small_class_name}});
    }

    @RequestMapping(value = "/update/{id}", method = RequestMethod.PUT)
    @ResponseBody
    private int update(HttpServletRequest request, @PathVariable int id) {
         {{class_name}} {{small_class_name}} = new  {{class_name}}();
        return {{small_class_name}}Service.update{{class_name}}({{small_class_name}});
    }

}
